﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _3.ReadAllTextWithExceptions
{
    class ReadAllTextWithExceptions
    {
        static void Main(string[] args)
        {
            string filename = @"C:\Windows\win.ini";
            StreamReader reader;
            try
            {
                reader = new StreamReader(filename);

                String text = reader.ReadToEnd();
                Console.WriteLine("File is readed successful.");
               Console.WriteLine("In file: {0}", text);
            }
            catch (System.IO.DirectoryNotFoundException directoryex)
            {
                Console.WriteLine("Directory not found! Message is: {0}", directoryex.Message);

            }
            catch (System.IO.FileNotFoundException filenotfoundex)
            {
                Console.WriteLine("File not found! Message is: {0}", filenotfoundex.Message);

            }
            catch (System.IO.PathTooLongException pathtoolong)
            {
                Console.WriteLine("Path too long! Message is: {0}", pathtoolong.Message);

            }
            catch (System.IO.IOException ioexceptions)
            {
                Console.WriteLine("Other exception catched! Message is: {0}", ioexceptions.Message);
            }
            finally
            {
                Console.WriteLine("Bye!");
                
            }
        }
    }
}